package com.example.administrator.wallet.utils;

import android.app.Activity;
import android.view.Window;
import android.view.WindowManager;

/**
 * Effect:调节屏幕亮度
 * <p>
 * Author:  CaiYapeng
 * <p>
 * Time  :  2018/7/9.
 */

public class DimbgUtils {

    public static void dimBackground(Activity mActivity, final float to) {
        Window window=mActivity.getWindow();
        WindowManager.LayoutParams wl = window.getAttributes();
        window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
//        wl.flags=WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
        wl.alpha=to;   //这句就是设置窗口里崆件的透明度的．０.０全透明．１.０不透明．
        window.setAttributes(wl);
        /*final Window window = mActivity.getWindow();
        ValueAnimator valueAnimator = ValueAnimator.ofFloat(from, to);
        valueAnimator.setDuration(500);
        valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                WindowManager.LayoutParams params = window.getAttributes();
                params.alpha = (Float) animation.getAnimatedValue();
                window.setAttributes(params);
            }
        });

        valueAnimator.start();*/
    }

}
